package cn.terrence.myrpc.common.rpc.common;

/**
 * 响应凭证
 * @author prestigeding@126.com
 *
 */
public class ResponseFuture {
	private Response response;
	public Response getResult() {
		if(response != null ) {
			return response;
		}
		/**
		 * 使用本身的对象锁即可
		 */
		synchronized (this) {
			if(response != null) return response;
			try {
				this.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		return response;
	}
	public void setResult(Response result) {
		this.response = result;
		synchronized (this) {
			this.notifyAll();
		}
		
	}
}
